def fibonacci_loop(num):
    count = 0
    if num == 0 or num == 1:
        return num
    # 初始化一个长度为30的数组a，用于存储斐波那契数列的值
    a = [0] * 30
    a[0] = a[1] = 1
    for i in range(2, num):
        count += 1
        a[i] = a[i - 1] + a[i - 2]
    print(f"查找次数为: {count}")
    return a[num - 1]

# 获取用户输入的数字 1 1 2 3 5 8
num = int(input("请输入一个数字: "))
result = fibonacci_loop(num)
print(result)